<?php

namespace app\common\model;

use think\Db;
use think\Model;

class OrderGoods extends Model{


    // 表名
    protected $name = 'order_goods';

    public function getImagesAttr($value, $data)
    {
        if ($value){
            $value=get_app_image_url($data['images']);
        }
        return $value;
    }

    public function order()
    {
        return $this->belongsTo('order', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
    /**
     * 通过商品查询规格详情
     */
    public static function getGoodsAttr($order_id){
        $list=Db::name('order_goods')
            ->alias('a')
            ->join('sp_goods_specification_sku b','a.sku_id=b.id','left')
            ->field('a.*,b.name as sku_name')
            ->where('a.order_id','=',$order_id)
            ->select();
        return $list;
    }

}